//数据模型
const mongoose = require('mongoose');
const Schema = mongoose.Schema;

// Create Schema
/* name: {
            type: String,
            required: 'Please enter your name',
            unique: true,
            trim: true */

//步骤2：创建schema，我们使用schema创建数据集合的结构
const UserSchema = new Schema({
  name: {
    type: String,
    required: true
  },
  email: {
    type: String,
    required: true
  },
  password: {
    type: String,
    required: true
  },
/*   avatar: { //图像
    type: String
  },*/
  identity: {
    type: String,
    required: true
  }, 
  date: {
    type: Date,
    default: Date.now
  } 
});

module.exports = User = mongoose.model('users', UserSchema);//返回值是一个类，故用大写命名

//在test数据库内的User集合中
